package 高效制胜._07;

import general_class.TreeNode;

/**
 * @author yzh
 * @version 1.0
 * @date 2021/9/13 10:15
 * 路径总和
 * 算法：树  深度优先搜索
 */
public class _112 {
    public boolean hasPathSum(TreeNode root, int targetSum) {
        if (root == null) return false;
        if (root.left == null && root.right == null) return targetSum - root.val == 0;
        return hasPathSum(root.left, targetSum - root.val)
                || hasPathSum(root.right, targetSum - root.val);
    }

    public static void main(String[] args) {
        String url = "xXccxxxXX";
        // 从第四个字符位置开始往后继续查找，包含当前位置
        System.out.println(url.indexOf("c", 3));  //3
        System.out.println(url.indexOf('X'));
    }

}
